package com.teradata.fbj.util;

import java.sql.Connection;

import org.springframework.stereotype.Component;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.teradata.fbj.pojo.linkParams;

@Component("GetConnection")
public class GetConnection{
		
	public Connection getConnection(linkParams lp) throws Exception{
		ComboPooledDataSource dataSource = new ComboPooledDataSource();
		dataSource.setDriverClass(lp.getDriverClass()); 
		dataSource.setJdbcUrl(lp.getBaseUrl()); 
		dataSource.setUser(lp.getUsername());  
		dataSource.setPassword(lp.getPassword());
		dataSource.setAutoCommitOnClose(false);
//		dataSource.setMinPoolSize(1);
//		dataSource.setMaxPoolSize(20);
//		dataSource.setMaxIdleTime(1800);
//		dataSource.setAcquireIncrement(2);
		// ---> 从连接池对象中，获取连接对象  
        Connection con = dataSource.getConnection();  
        return con;
	}
}
